package com.usain.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
   //访问Handle控制器 访问Controller之前
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        //放行 满足放行 不满足拦截 或许token 解析是否合法 合法放行 不合法拦截并传递给前端
        String requestURI = request.getRequestURI();
        System.out.println("进入拦截器"+requestURI);
        if (requestURI.contains("/emp/three")){
            return true;
        }


        return false;
    }
    //访问Controller之后
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

    }

    //访问之后
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    }
}
